home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / setpgms.zip / SETNOW.ASM < prev    next >
Assembly Source File  |  1987-01-15  |  5KB  |  231 lines

  1.                page     65,132
  2.  
  3.                ;Copyright 1986, Arnold B. Krueger
  4.                ;All rights reserved. Contact "ARNY KRUEGER"
  5.                ;at the EXEC-PC BBS (414-964-5160) for permission 
  6.                ;to use commercially.
  7.  
  8.                ;SETNOW places the current time and date into the
  9.                ;environment variables DATE and TIME. Usage is:
  10.                ;
  11.                ;errorlevels are:
  12.                ;               0  if all goes well
  13.                ;               1 or 2 for env_set detected errors:
  14.                ;                    1 - not at DOS 2.0 or above
  15.                ;                    2 - error updating environment
  16.                ;                        (an error message will be typed)
  17.  
  18. code_seg         segment para public
  19.                  assume  cs:code_seg,ds:code_seg,ss:code_seg,es:code_seg
  20.                  extrn   env_set:near
  21.  
  22.                  org   80h
  23. psp_parml        db    ?                    ;length of parms
  24. psp_parm         db    ?                    ;actual parms
  25.  
  26.                  org   100h                 ; .COM file format
  27. begin:           jmp   main                 ; Skip around data declarations
  28. copyright        db    'Copyright 1986, Arnold B. Krueger GPW, MI 48236'
  29.  
  30. byte_radix       db    10
  31.  
  32. bin_to_ascii     proc    near           ; Convert binary number to 2-digit ASCII
  33.         push     ax
  34.         cbw                             ; Convert al to word for division
  35.         div      byte_radix             ; Divide al by radix
  36.         add      al,48                  ; Convert quotient in al to ASCII
  37.         stosb                           ; Store to location pointed to by di
  38.         add      ah,48                  ; Convert remainder in ah to ASCII
  39.         mov      al,ah                  ; Move to al for store
  40.         stosb                           ; Store to location pointed to by di
  41.         pop      ax
  42.         ret 
  43. bin_to_ascii     endp
  44.  
  45. cr               equ   13
  46. lf               equ   10
  47.  
  48. set_date         db    set_date_len-1,'DATE='
  49. set_date_now     db    'mm/dd/yy'
  50. set_date_len     equ   $-set_date
  51. set_time         db    set_time_len-1,'TIME='
  52. set_time_now     db    'hh:mm:ss'
  53. set_time_len     equ   $-set_time
  54.  
  55. release_error    db    1,'Need at least DOS 2.0 to run SETNOW',cr,lf,'$'
  56. env_error        db    2,'Error updating the DOS environment',cr,lf,'$'
  57.  
  58. main:
  59.         mov      ah,30h              ; get dos release number
  60.         int      21h               
  61.         cmp      al,1                ; above release 1.x
  62.         ja       get_date            ; if not, don't ask for current directry
  63.  
  64.         mov      si,offset release_error
  65.         jmp      error_exit
  66.  
  67. get_date:
  68.         mov      ah,02ah             ;ask for date
  69.         int      21h                 ; dl=dd, dh=mm, cx=yy
  70.  
  71.         mov      di,offset set_date_now
  72.         mov      al,dh
  73.         call     bin_to_ascii
  74.         inc      di
  75.         mov      al,dl
  76.         call     bin_to_ascii
  77.         inc      di
  78.         sub      cx,1900
  79.         mov      al,cl
  80.         call     bin_to_ascii
  81.  
  82.         mov      si,offset set_date
  83.  
  84.         call     env_set
  85.         jc       set_error
  86.  
  87.         mov      ah,02ch             ;ask for time
  88.         int      21h                 ; ch=hh, cl=mm, dh=ss dl=.ss (100ths)
  89.  
  90.         mov      di,offset set_time_now
  91.         mov      al,ch
  92.         call     bin_to_ascii
  93.         inc      di
  94.         mov      al,cl
  95.         call     bin_to_ascii
  96.         inc      di
  97.         mov      al,dh
  98.         call     bin_to_ascii
  99.  
  100.         mov      si,offset set_time
  101.  
  102.         call     env_set
  103.  
  104.         jc       set_error
  105.  
  106.         xor      al,al               ;set al=0
  107.  
  108. exit:
  109.         mov      ah,4ch              ;terminate program, set errorlevel from al
  110.         int      21h
  111.  
  112. set_error:
  113.         mov      si,offset env_error
  114.  
  115. error_exit:
  116.         lodsb                        ;reset al with errorlevel
  117.         push     ax                  ;save it
  118.         mov      dx,si               ;get start of message
  119.         mov      ah,9h               ;type it out
  120.         int      21h               
  121.         pop      ax                  ;reset al with errorlevel
  122.         jmp      exit
  123.  
  124. code_seg ends
  125.          end    begin
  126. 
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170. (·l╠°
  171. Θ<xyç3≤ⁿ ççççççç3 29çç3 213≤ⁿ ççççççç3 213≤ⁿ ççççççç?29çç  end    begin
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188. ds
  189.         end    begin
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  ends
  203.         end    begin
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.   end    begin
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217. 
  218.      BEGIN
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.